package com.wdf.rest.service;

import org.apache.http.HttpEntity;

import android.content.Context;

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.wdf.helper.ConfigInfo;

public class GameForumRestClient {
	
	private static AsyncHttpClient client = new AsyncHttpClient();
	
	
	static{
	        client.setTimeout(11000);
	    }

	
    public static void get(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
        client.get(getAbsoluteUrl(url), params, responseHandler);
    }
    
    public static void post(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
    	
           client.post(getAbsoluteUrl(url), params, responseHandler);
    }
    
    public static void post(Context context, String url, HttpEntity entity, String contentType,  AsyncHttpResponseHandler responseHandler) {
    	   client.post(context, getAbsoluteUrl(url), entity, contentType, responseHandler);
    }
    
    public static void put(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
    	
        client.put(getAbsoluteUrl(url), params, responseHandler);
 }
	
    private static String getAbsoluteUrl(String relativeUrl) {
        return ConfigInfo.restUrl + relativeUrl;
    }
         
}
